#include <iostream>
#include <climits> 
using namespace std;
void findSecondMin(int arr[], int n, int &min1, int &min2) {
    if (n < 2) {
        cerr << "Array must have at least two elements." << endl;
        return;
    }
    min1 = INT_MAX;
    min2 = INT_MAX;
    for (int i = 0; i < n; i++) {
        if (arr[i] < min1) {
            min2 = min1;
            min1 = arr[i];
        } else if (arr[i] < min2 && arr[i] != min1) {
            min2 = arr[i];
        }
    }
    if (min2 == INT_MAX) {
        cerr << "There is no second minimum value in the array." << endl;
    }
}
int main() {
    int n;
    cout << "输入数组长度: ";
    cin >> n;

    int a[100];
    cout << "输入数组元素: " << endl;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int min1, min2;
    findSecondMin(a, n, min1, min2);

    if (min2 != INT_MAX) {
        cout << "最小值是: " << min1 << endl;
        cout << "第二小值是: " << min2 << endl;
    }

    return 0;
}